<template>
	<view class="apply-after-container">
		
		<!-- 商品信息 -->
		<view class="product-info">
			<view class="product-card">
				<view class="image-container">
					<image class="product-image" :src="order.orderSpeciDetailVoList[0].image | avatarUrlFind('1')" mode="aspectFill"></image>
					<view v-if="order.isPoints==='1'" class="points-order-tag">积分订单</view>
				</view>
				<view class="product-details">
					<view class="product-name">{{ order.orderSpeciDetailVoList[0].drugName }}</view>
					<view class="product-specs">{{ order.orderSpeciDetailVoList[0].speciName }}</view>
					<!-- <view class="product-status">{{ productInfo.status }}</view> -->
					<view class="product-price">￥{{ order.payableAmount }}</view>
				</view>
			</view>
		</view>
		
		<!-- 售后类型选择 -->
		<view class="after-sale-options">
			<view class="option-item" @click="selectAfterSaleType('refund_only')">
				<view class="option-content">
					<view class="option-title">我要退款（无需退货）</view>
					<view class="option-desc">未收到货或工作人员沟通协商后申请</view>
				</view>
				<text class="iconfont icon-arrow-right"></text>
			</view>
			
			<view class="option-item" @click="selectAfterSaleType('return_refund')">
				<view class="option-content">
					<view class="option-title">退货退款</view>
					<view class="option-desc">需要您寄回已收到的货物</view>
				</view>
				<text class="iconfont icon-arrow-right"></text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderId: '',
                order: {}
			}
		},
		onLoad(options) {
            this.order = JSON.parse(decodeURIComponent(options.order))
			console.log(this.order)
		},
		methods: {
			// 返回上一页
			goBack() {
				uni.navigateBack();
			},
			
			
			// 选择售后类型
			selectAfterSaleType(type) {
				let title = '';
				
				switch(type) {
					case 'refund_only':
						title = '申请退款';
						break;
					case 'return_refund':
						title = '申请退货退款';
						break;
				}
				
				// 构建跳转URL，将订单信息、类型和标题作为参数传递
				const orderParam = encodeURIComponent(JSON.stringify(this.order));
				const titleParam = encodeURIComponent(title);
				
				// 跳转到对应的申请页面
				uni.navigateTo({
					url: `/subPackage_1/pages/order/return-refund?order=${orderParam}&type=${type}&title=${titleParam}`
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.apply-after-container {
		background-color: #f5f5f5;
		min-height: 100vh;
	}
	
	// 导航栏
	.nav-bar {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 88rpx;
		background-color: #fff;
		padding: 0 32rpx;
		border-bottom: 1rpx solid #f0f0f0;
		position: sticky;
		top: 0;
		z-index: 999;
		
		.nav-left, .nav-right {
			width: 60rpx;
			height: 60rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			
			.iconfont {
				font-size: 36rpx;
				color: #333;
			}
		}
		
		.nav-title {
			font-size: 36rpx;
			font-weight: 500;
			color: #333;
		}
	}
	
	// 商品信息
	.product-info {
		// margin-top: 20rpx;
		
		.product-card {
			background-color: #fff;
			padding: 32rpx;
			display: flex;
			align-items: flex-start;
			
			.image-container {
				position: relative;
				margin-right: 24rpx;
				flex-shrink: 0;
			}
			
			.product-image {
				width: 160rpx;
				height: 160rpx;
				border-radius: 12rpx;
			}

			.points-order-tag {
				position: absolute;
				top: 0rpx;
				left: 0rpx;
				background-color: #FFCC00;
				color: #fff;
				font-size: 20rpx;
				padding: 4rpx 8rpx;
				border-bottom-right-radius: 12rpx;
				line-height: 1.2;
				z-index: 1;
			}
			
			.product-details {
				flex: 1;
				
				.product-name {
					font-size: 28rpx;
					color: #333;
					line-height: 40rpx;
					margin-bottom: 16rpx;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
				}
				
				.product-specs {
					font-size: 24rpx;
					color: #999;
					margin-bottom: 12rpx;
				}
				
				.product-status {
					font-size: 24rpx;
					color: #666;
					margin-bottom: 16rpx;
					display: -webkit-box;
					-webkit-line-clamp: 1;
					-webkit-box-orient: vertical;
					overflow: hidden;
				}
				
				.product-price {
					font-size: 32rpx;
					color: #ff6b35;
					font-weight: 600;
				}
			}
		}
	}
	
	// 售后选项
	.after-sale-options {
		margin-top: 20rpx;
		padding: 0 20rpx;
		
		.option-item {
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 40rpx 32rpx;
			margin-bottom: 30rpx;
			background-color: #fff;
			border-radius: 20rpx;
			
			&:last-child {
				margin-bottom: 0;
			}
			
			&:active {
				background-color: #f8f8f8;
			}
			
			.option-content {
				text-align: center;
				
				.option-title {
					font-size: 32rpx;
					color: #333;
					font-weight: 500;
					margin-bottom: 12rpx;
				}
				
				.option-desc {
					font-size: 26rpx;
					color: #999;
					line-height: 36rpx;
				}
			}
			
			.iconfont {
				display: none;
			}
		}
	}
</style>